#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:

    vector<vector<int>> vv;

    vector<vector<int>> permute(vector<int>& nums)
    {
        vector<bool> judge(nums.size(), true);
        vector<int> v;

        _caculate(nums, judge, v);
        return vv;
    }

    void _caculate(vector<int>& nums, vector<bool>& judge, vector<int>& v)
    {
        if (v.size() == nums.size())
        {
            vv.push_back(v);
            return;
        }

        for (int i = 0; i < nums.size(); i++)
        {
            if (judge[i] == true)
            {
                v.push_back(nums[i]);
                judge[i] = false;
                _caculate(nums, judge, v);

                judge[i] = true;
                v.pop_back();
            }
        }
    }
};

int main()
{

    Solution so;
    vector<int> v{ 1,2,3 };
    so.permute(v);

    return 0;
}